import * as mysql from 'mysql';
import * as os from 'os';


const 我的苹果笔记本 = '17.2.0';
const 公司电脑 = '';
let PASSWORD;
switch (os.release()) {
    case 我的苹果笔记本:
        PASSWORD = '55722168';
        break;
    case 公司电脑:
        PASSWORD = '55722';
        break;
}

// const IP = '118.190.117.227';
const IP = '192.168.188.35';

/**服务器配置信息 */
export default class Configs_win {
    static HALL_IP = IP;
    static HALL_CLIENT_PORT = 9001;
    static HALL_ROOM_PORT = 9002;
    static ACCOUNT_PRI_KEY = '^&*#$%()@';
    static ROOM_PRI_KEY = '~!@#$(*&^%$&';
    static LOCAL_IP = IP;

    static mysql() {
        // let config: mysql.IPoolConfig = {
        //     host: IP,
        //     user: 'root',
        //     password: 'mylove321',
        //     database: 'nodejs',
        //     port: 3306
        // };
        let config: mysql.IPoolConfig = {
            host: IP,
            user: 'root',
            password: '',
            database: 'nodejs',
            port: 3306
        };
        return config;

    }
    /**
     * 账号服务器配置
     */
    static account_server() {
        return <account_server>{
            /**
             * 9000
             * 账号服务器端口
             */
            CLIENT_PORT: 9000,
            /**
             * 客户端大厅服务器IP地址  
             * 118.190.117.227
             */
            HALL_IP: this.HALL_IP,
            /**
             * 客户端大厅服务器连接的端口号 9001
             */
            HALL_CLIENT_PORT: this.HALL_CLIENT_PORT,
            /**
             * 账户秘钥
             */
            ACCOUNT_PRI_KEY: this.ACCOUNT_PRI_KEY,

            /**
             * 发牌服务器IP地址 118.190.117.227
             */
            DEALDER_API_IP: this.LOCAL_IP,
            /**
             * 发牌服务器端口 12581
             */
            DEALDER_API_PORT: 12581,
            /**
             * 版本号 20161227
             */
            VERSION: '20161227',
            /**
             * 游戏下载地址 http://118.190.117.227:9000/download
             */
            APP_WEB: 'http://' + IP + ':9000/download'
        };
    }
    /**
     * 大厅服务器配置
     */
    static hall_server() {
        return <hall_server>{
            /**
             * 大厅服务器IP 118.190.117.227
             */
            HALL_IP: this.HALL_IP,
            /**大厅服务器端口9001 */
            CLIENT_PORT: this.HALL_CLIENT_PORT,
            /**
             * 连接房间的IP 118.190.117.227
             */
            FOR_ROOM_IP: this.LOCAL_IP,
            /**
             * 9002
             */
            ROOM_PORT: this.HALL_ROOM_PORT,
            /**
             * 账号秘钥
             */
            ACCOUNT_PRI_KEY: this.ACCOUNT_PRI_KEY,
            ROOM_PRI_KEY: this.ROOM_PRI_KEY
        };
    }

    /**
     * 游戏进行中的服务器配置
     */
    static game_server() {
        return <game_server>{
            /**
             * 服务器ID号
             */
            SERVER_ID: 1,

            /**暴露给大厅服务器的HTTP端口号 9003*/
            HTTP_PORT: 9003,

            /**HTTP TICK的间隔时间5秒，用于向大厅服务器回报情况 */
            HTTP_TICK_TIME: 5000,

            /**大厅服务器IP 118.190.117.227*/
            HALL_IP: this.LOCAL_IP,
            /**
             * 118.190.117.227
             */
            FOR_ROOM_IP: this.LOCAL_IP,

            /**大厅服务器端口 9002*/
            HALL_PORT: this.HALL_ROOM_PORT,

            /**与大厅服务器协商好的通信加密key */
            ROOM_PRI_KEY: this.ROOM_PRI_KEY,

            /**暴露给客户端的接口 118.190.117.227*/
            CLIENT_IP: this.HALL_IP,
            /**
             * 10000
             */
            CLIENT_PORT: 10000
        };
    }
}



export const game_event_map: game_event_map = {
    CONNECTION: 'connection',
    GAME_DINGQUE: 'game_dingque',
    GAME_DINGQUE_NOTIFY: 'game_dingque_notify',
    GAME_DINGQUE_FINISH: 'game_dingque_finish',
    PENG_NOTIFY: 'peng_notify',
    GANG_NOTIFY: 'gang_notify',
    GAME_BEGIN: 'game_begin',
    NEW_USER: 'new_user',
    USER_STATE_CHANGED: 'user_state_changed',
    GAME_NUM: 'game_num',
    GAME_HUANPAI: 'game_huanpai',
    HUANPAI_NOTIFY: 'huanpai_notify',
    GAME_HUANPAI_OVER: 'game_huanpai_over',
    VOICE_MSG: 'voice_msg',
    CHAT_PUSH: 'chat_push',
    QUICK_CHAT_PUSH: 'quick_chat_push',
    EMOJI_PUSH: 'emoji_push',
    GAME_CHUPAI: 'game_chupai',
    GAME_END: 'game_end',
    QUICK_CHAT: 'quick_chat',
    EMOJI: 'emoji',
    CHAT: 'chat',
    GAME_SYNC: 'game_sync',
    GAME_CHUPAI_NOTIFY: 'game_chupai_notify',
    GUO_NOTIFY: 'guo_notify',
    GAME_MOPAI: 'game_mopai',
    HUPAI: 'hupai',
    HANGANG_NOTIFY: 'hangang_notify',
    DISSOLVE_AGREE: 'dissolve_agree',
    LOGIN: 'login',
    DISSOLVE_REJECT: 'dissolve_reject',
    DISSOLVE_REQUEST: 'dissolve_request',
    DISSOLVE_NOTICE: 'dissolve_notice',
    DISSOLVE_CANCEL: 'dissolve_cancel',
    HUANPAI: 'huanpai',
    MJ_CLICKED: 'mj_clicked',
    DISCONNECT: 'disconnect',
    LOGIN_FINISHED: 'login_finished',
    CHUPAI: 'chupai',
    GAME_HOLDS: 'game_holds',
    CHECK_IP: 'check_ip',
    GAME_ACTION: 'game_action',
    MJ_COUNT: 'mj_count',
    GUO_RESULT: 'guo_result',
    LOGIN_RESULT: 'login_result',
    GAME_OVER: 'game_over',
    PENG: 'peng',
    GANG: 'gang',
    HU: 'hu',
    GUO: 'guo',
    PUSH_NOTICE: 'push_notice',
    DISPRESS: 'dispress',
    EXIT: 'exit',
    EXIT_RESULT: 'exit_result',
    EXIT_NOTIFY_PUSH: 'exit_notify_push',
    USER_STATE_PUSH: 'user_state_push',
    USER_READY_PUSH: 'user_ready_push',
    GAME_HOLDS_PUSH: 'game_holds_push',
    GAME_BEGIN_PUSH: 'game_begin_push',
    GAME_PLAYING_PUSH: 'game_playing_push',
    GAME_PLAYING: 'game_playing',
    GAME_SYNC_PUSH: 'game_synv_push',
    GAME_DINGQUE_PUSH: 'game_dingque_push',
    GAME_HUANPAI_PUSH: 'game_huanpai_push',
    HANGANG_NOTIFY_PUSH: 'hangang_notify_push',
    GAME_ACTION_PUSH: 'game_action_push',
    GAME_CHUPAI_PUSH: 'game_chupai_push',
    GAME_NUM_PUSH: 'game_num_push',
    GAME_OVER_PUSH: 'game_over_push',
    MJ_COUNT_PUSH: 'mj_count_push',
    HU_PUSH: 'hu_push',
    GAME_CHUPAI_NOTIFY_PUSH: 'game_chupai_notify_push',
    GAME_MOPAI_PUSH: 'game_mopai_push',
    GUO_NOTIFY_PUSH: 'guo_notify_push',
    GUOHU_PUSH: 'guohu_push',
    GAME_HUANPAI_OVER_PUSH: 'game_huanpai_over_push',
    PENG_NOTIFY_PUSH: 'peng_notify_push',
    GANG_NOTIFY_PUSH: 'gang_notify_push',
    GAME_DINGQUE_NOTIFY_PUSH: 'game_dingque_notify_push',
    GAME_DINGQUE_FINISH_PUSH: 'game_dingque_finish_push',
    DISSOLVE_NOTICE_PUSH: 'dissolve_notice_push',
    DISSOLVE_CANCEL_PUSH: 'dissolve_cancel_push',
    VOICE_MSG_PUSH: 'voice_msg_push',
    READY: 'ready',
    NEW_USER_COMES_PUSH: 'new_user_comes_push',
    DINGQUE: 'dingque',
    DISPRESS_PUSH: 'dispress_push',
    GAME_PING: 'game_ping',
    GAME_PONG: 'game_pong',
};

export const httpRouterMap: httpRouterMap = {
    /**
     * '/get_serverinfo'  
     * 监听请求服务器版本号跟下载地址 
     */
    GET_SERVERINFO: '/get_serverinfo',

    /**
     * '/guest'
     * 监听请求游客登陆
     */
    GUEST: '/guest',

    /**
     * '/login'
     * 登录游戏
     */
    LOGIN: '/login',
    CREATE_USER: '/create_user',
    GET_USER_STATUS: '/get_user_status',
    GET_MESSAGE: '/get_message',
    ENTER_PRIVATE_ROOM: '/enter_private_room',
    CREATE_PRIVATE_ROOM: '/create_private_room',
    RESISTER_GS: '/register_gs',
    CREATE_ROOM: '/create_room',
    ENTER_ROOM: '/enter_room',
    IS_ROOM_RUNING: '/is_room_runing',
};


interface httpRouterMap {
    /**
     * '/get_serverinfo'  
     * 监听请求服务器版本号跟下载地址 
     */
    GET_SERVERINFO: '/get_serverinfo';
    /**
     * '/guest'
     * 监听请求游客登陆
     */
    GUEST: '/guest';

    /**
     * '/login'
     * 监听登录游戏
     */
    LOGIN: '/login';

    /**
     * 监听创建用户
     */
    CREATE_USER: '/create_user';

    /**
     * 监听获取用户gems的消息
     */
    GET_USER_STATUS: '/get_user_status';
    /**
     * 监听获取公告信息及版本号的消息
     */
    GET_MESSAGE: '/get_message';

    /**
     * 监听进入房间的消息
     */
    ENTER_PRIVATE_ROOM: '/enter_private_room';

    /**
     * 房间管理服务器监听创建房间的消息
     */
    CREATE_PRIVATE_ROOM: '/create_private_room';

    /**
     * 监听游戏服务器注册或发来消息的消息(更新所有分布游戏服务器的使用率)
     */
    RESISTER_GS: '/register_gs';

    /**
     * 游戏服务器监听创建房间的消息
     */
    CREATE_ROOM: '/create_room';

    /**
     * 进入房间
     */
    ENTER_ROOM: '/enter_room';

    /**
     * 游戏服务器监听检查房间是否运行中
     */
    IS_ROOM_RUNING: '/is_room_runing';
}
